package com.jiazhong.IO流.带有缓冲区的字符流;

import java.io.*;
import java.nio.charset.Charset;

public class 带有缓冲区的字符流 {
    public static void main(String[] args) throws IOException {
//        bufferedWriterDemo();
        bufferedReaderDemo();
    }

    /**
     * 带有缓冲区的字符输出流
     */
    public static void bufferedWriterDemo() throws IOException {
        //创建带有缓冲区的字符输出流对象
        BufferedWriter writer = new BufferedWriter(new FileWriter("d:/abc.txt",true));
        writer.write("带有缓冲区的字符流");
        writer.newLine();//输出一个换行符
        writer.flush();
        writer.close();

    }

    private static void bufferedReaderDemo() throws IOException {
        //创建带有缓冲区的字符流对象
       /*BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(
               new FileInputStream(
                       "D:\\Study\\MySQL8\\mysql-8.0.26-winx64\\mysql-8.0.26-winx64\\安装说明.txt"
               ),"GBK")
       );*/
        BufferedReader bufferedReader = new BufferedReader(new FileReader( "D:\\Study\\MySQL8\\mysql-8.0.26-winx64\\mysql-8.0.26-winx64\\安装说明.txt"));
        String str=null;
       while((str=bufferedReader.readLine())!=null){
           System.out.println(str);
       }
        bufferedReader.close();

    }
}
